/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;


/**
 * @author LongYang
 * @website https://el-admin.vip
 * @description /
 * @date 2021-06-28
 **/
@Entity
@Data
@Table(name = "kw_exam")
@EntityListeners(AuditingEntityListener.class)
public class KwExam implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "系统主键")
    private Integer id;

    @Column(name = "name_cn")
    @ApiModelProperty(value = "考试名称")
    private String nameCn;

    @Column(name = "address")
    @ApiModelProperty(value = "地点")
    private String address;

    @Column(name = "start_time", nullable = false)
    @NotNull(message = "考试开始时间不可为空")
    @ApiModelProperty(value = "开始时间")
    private Timestamp startTime;

    @Column(name = "end_time", nullable = false)
    @NotNull(message = "考试结束时间不可为空")
    @ApiModelProperty(value = "结束时间")
    private Timestamp endTime;

    @Column(name = "status")
    @ApiModelProperty(value = "状态(0：正常，1：结束)")
    private String status;

    @Column(name = "teacher_count")
    @ApiModelProperty(value = "本次监考老师人数")
    private Integer teacherCount;

    @Column(name = "del_flag")
    @ApiModelProperty(value = "删除标识（0：未删除，2：已删除）")
    private String delFlag;

    @Column(name = "public_exam_id")
    @ApiModelProperty(value = "考试公开信息id(暂不使用，此处添加为预防)")
    private Integer publicExamId;

//    @Column(name = "exam_rule")
//    @ApiModelProperty(value = "注意事项")
//    private String examRule;

//    @ApiModelProperty("考生须知(只能考生查看)")
//    @Column(name = "student_notes",columnDefinition = "longtext COMMENT '考生须知'")
//    private String studentNotes;
//
//    @ApiModelProperty("监考规则(只能教师查看)")
//    @Column(name = "tearcher_notes",columnDefinition = "longtext COMMENT '监考规则'")
//    private String tearcherNotes;



    @Column(name = "create_time", columnDefinition = "datetime COMMENT '创建时间'")
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @CreatedDate
    private Date createTime;

    @Column(name = "update_time", columnDefinition = "datetime COMMENT '修改时间'")
    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @CreatedDate
    @LastModifiedDate
    private Date updateTime;

    @ApiModelProperty("总考试id")
    @Column(name = "generalId", columnDefinition = "int NOT NULL COMMENT '总考试id'")
    private Integer generalId;



    @Transient
    @ApiModelProperty("当前登录用户学院本次考试需上报的考务人员数量")
    private Integer reportStaffNumber;

    @Transient
    @ApiModelProperty("当前登录用户学院本次考试需上报的监考人员数量数量")
    private Integer reportTeacherNumber;

    @Transient
    @ApiModelProperty("当前登录用户学院已经上报的考务人员数量")
    private Integer reportedStaffCount;

    @Transient
    @ApiModelProperty("当前登录用户学院已经上报的监考人员数量")
    private Integer reportedTeacherCount;


    public void copy(KwExam source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}